<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul></ul>
</body>
</html>
<script>

    //封装ajax请求
    function ajax (method, url, cb){
        let xhr = new XMLHttpRequest();
        xhr.open(method,url);
        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4) {
                cb(JSON.parse(xhr.responseText));
            }
        }
        xhr.send();
    }

    ajax('get', `./news.json`, function (data) {
            var str = data.map((item, index) => {
                return `<li>${item}</li>`
            }).join('')
            document.querySelector('ul').innerHTML = str;
        });
</script>